set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/* *******************************************************************
** DATE :
** Writer :
** Memo :
******************************************************************** */
CREATE PROCEDURE [dbo].[TSP_Recruit_GetInfo]
(
	@IsTransaction	tinyint			= 0
,	@ErrorCode		int				= 0		OUTPUT
,	@ErrorMessage	nvarchar( 1000 )= ''	OUTPUT

,	@n4RecruitNo	int				OUTPUT
,	@strName	nvarchar(60)	= NULL	OUTPUT
,	@strPersonalNo	varchar(50)	= NULL	OUTPUT
,	@strPhone	varchar(14)	= NULL	OUTPUT
,	@strEmail	varchar(200)	= NULL	OUTPUT
,	@strPostNo	varchar(10)	= NULL	OUTPUT
,	@strAddress	nvarchar(600)	= NULL	OUTPUT
,	@strHopeStore	nvarchar(400)	= NULL	OUTPUT
,	@n1JobTime	tinyint	= NULL	OUTPUT
,	@strAcademic	nvarchar(MAX)	= NULL	OUTPUT
,	@strCareer	nvarchar(MAX)	= NULL	OUTPUT
,	@strLicense	nvarchar(MAX)	= NULL	OUTPUT
,	@strFileURL	varchar(200)	= NULL	OUTPUT
,	@n1Status	tinyint	= NULL	OUTPUT
,	@dtCreateDate	datetime	= NULL	OUTPUT
,	@dtModifyDate	datetime	= NULL	OUTPUT
,	@strManagerName	nvarchar(50)	= NULL	OUTPUT
,	@strDescription	nvarchar(MAX)	= NULL	OUTPUT
)
as
Set NOCOUNT ON

-- Frk Default Value
DECLARE @FrkDateNow DateTime
DECLARE @FrkRowCount int
DECLARE @FrkTranCount int
DECLARE @FrkErrorCode int
DECLARE @FrkErrorMessage nvarchar( 1000 )
Set @FrkDateNow = GetDate()
set @FrkTranCount = @@TRANCOUNT
-- Frk Check


If ( @IsTransaction = 0 )
Begin
	If ( @FrkTranCount < 1 )
	Begin
		Set @FrkErrorCode = -1
		Set @FrkErrorMessage = 'Transaction.'
		goto ERROR
	End
	Else If ( @FrkTranCount > 1 )
	Begin
		Set @FrkErrorCode = -2
		Set @FrkErrorMessage = 'Transaction.'
		goto ERROR
	End
End
Else
Begin
	If ( @FrkTranCount <> 0 )
	Begin
		Set @FrkErrorCode = -3
		Set @FrkErrorMessage = 'Transaction.'
		goto ERROR
	End
	Begin Tran
End

-- Implementation

SELECT
	@strName = strName
,	@strPersonalNo = strPersonalNo
,	@strPhone = strPhone
,	@strEmail = strEmail
,	@strPostNo = strPostNo
,	@strAddress = strAddress
,	@strHopeStore = strHopeStore
,	@n1JobTime = n1JobTime
,	@strAcademic = strAcademic
,	@strCareer = strCareer
,	@strLicense = strLicense
,	@strFileURL = strFileURL
,	@n1Status = n1Status
,	@dtCreateDate = dtCreateDate
,	@dtModifyDate = dtModifyDate
,	@strManagerName = strManagerName
,	@strDescription = strDescription
FROM
	dbo.TB_Recruit WITH (NOLOCK)
WHERE
	@n4RecruitNo = n4RecruitNo


-- Frk Error Check
SELECT
	@FrkErrorCode = @@ERROR
,	@FrkRowCount = @@RowCount

-- End

COMPLETE:
	If ( @IsTransaction <> 0 )
	Begin
		If ( @@TRANCOUNT = 1 )
		Begin
			Commit Tran
		End
	End
	SET @ErrorCode = 0
	SET @ErrorMessage = ''
	return 0
ERROR:
	If ( @IsTransaction <> 0 )
	Begin
		If ( @@TRANCOUNT = 1 )
		Begin
			Rollback Tran
		End
	End
	SET @ErrorCode = @FrkErrorCode
	SET @ErrorMessage = @FrkErrorMessage
	return @FrkErrorCode
